from django.shortcuts import render
from django.views import View

from apps.goods.models import Commodity


class DetailView(View):
    """商品详情页"""

    def get(self, request, sku_id):
        """提供商品详情页"""

        # 获取当前sku的信息
        try:
            sku = Commodity.objects.get(id=sku_id)
        except :
            return render(request, '404.html')

        context = {
            'sku': sku,
        }

        return render(request, 'detail.html', context)